<?php

namespace JLPay\Models\Openmerch\Bill;

use JLPay\Models\BaseResponse;

/**
 * 订单信息查询响应
 * 
 * @author liaochangyi
 * @since 2025-01-25
 */
class OrderInfoQueryResponse extends BaseResponse
{
    protected ?string $merchNo = null;  // 商户号
    protected ?string $termNo = null;  // 终端号
    protected ?string $outOrderId = null;  // 客户订单号
    protected ?string $orderId = null;  // 嘉联订单号
    protected ?string $chnTransactionId = null;  // 渠道订单号，微信、支付宝、银联侧的订单号（码付交易时有）
    protected ?string $oriOrderId = null;  // 原嘉联订单号（退款交易时有）
    protected ?string $transTime = null;  // 交易时间（yyyy-MM-dd HH:mm:ss）
    protected ?string $amount = null;  // 交易金额（单位为分）
    protected ?string $feeType = null;  // 计费类型
    protected ?string $cardType = null;  // 卡类型，0：借记卡 1：贷记卡 2：余额
    protected ?string $transFee = null;  // 应收手续费，单位为分，收款交易手续费为正值，退款交易手续费为负值，无手续费为0，说明：该手续费为优惠减免前的手续费
    protected ?string $finnalFee = null;  // 实收手续费，单位为分，收款交易手续费为正值（优惠减免后手续费）退款交易手续费为负值，无手续费为0，说明：该手续费为优惠减免后的手续费，且以此字段作为该笔订单手续费
    protected ?string $subOpenid = null;  // 用户身份id（码付交易时有）
    protected ?string $remark = null;  // 备注产品来源：立牌/电子码牌、银行卡、外接码付、订单POS、智能SDK

    /**
     * 构造函数
     *
     * @param array $data 响应数据
     */
    public function __construct(array $data)
    {
        parent::__construct($data);
        
        $this->merchNo = $data['merch_no'] ?? null;
        $this->termNo = $data['term_no'] ?? null;
        $this->outOrderId = $data['out_order_id'] ?? null;
        $this->orderId = $data['order_id'] ?? null;
        $this->chnTransactionId = $data['chn_transaction_id'] ?? null;
        $this->oriOrderId = $data['ori_order_id'] ?? null;
        $this->transTime = $data['trans_time'] ?? null;
        $this->amount = $data['amount'] ?? null;
        $this->feeType = $data['fee_type'] ?? null;
        $this->cardType = $data['card_type'] ?? null;
        $this->transFee = $data['trans_fee'] ?? null;
        $this->finnalFee = $data['finnal_fee'] ?? null;
        $this->subOpenid = $data['sub_openid'] ?? null;
        $this->remark = $data['remark'] ?? null;
    }

    /**
     * 获取商户号
     *
     * @return string|null
     */
    public function getMerchNo(): ?string
    {
        return $this->merchNo;
    }

    /**
     * 获取终端号
     *
     * @return string|null
     */
    public function getTermNo(): ?string
    {
        return $this->termNo;
    }

    /**
     * 获取客户订单号
     *
     * @return string|null
     */
    public function getOutOrderId(): ?string
    {
        return $this->outOrderId;
    }

    /**
     * 获取嘉联订单号
     *
     * @return string|null
     */
    public function getOrderId(): ?string
    {
        return $this->orderId;
    }

    /**
     * 转换为数组
     *
     * @return array
     */
    public function toArray(): array
    {
        $data = parent::toArray();
        $data['merch_no'] = $this->merchNo;
        $data['term_no'] = $this->termNo;
        $data['out_order_id'] = $this->outOrderId;
        $data['order_id'] = $this->orderId;
        $data['chn_transaction_id'] = $this->chnTransactionId;
        $data['ori_order_id'] = $this->oriOrderId;
        $data['trans_time'] = $this->transTime;
        $data['amount'] = $this->amount;
        $data['fee_type'] = $this->feeType;
        $data['card_type'] = $this->cardType;
        $data['trans_fee'] = $this->transFee;
        $data['finnal_fee'] = $this->finnalFee;
        $data['sub_openid'] = $this->subOpenid;
        $data['remark'] = $this->remark;
        return $data;
    }
} 